//
//  ActivityApplyViewController.m
//  RainbowFM
//
//  Created by chenli on 14/12/27.
//  Copyright (c) 2014年 RB. All rights reserved.
//

#import "ActivityApplyViewController.h"
#import "ActivityModel.h"

@interface ActivityApplyViewController (){
    NSInteger sexIndex;
}

@property (weak, nonatomic) IBOutlet UIButton *mButton;
@property (weak, nonatomic) IBOutlet UIButton *fButton;
@property (weak, nonatomic) IBOutlet UITextField *phoneField;
@property (weak, nonatomic) IBOutlet UITextField *nameField;

@end

@implementation ActivityApplyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (IBAction)checkSexAction:(UIButton *)sender {
    if (sender == _mButton) {
        self.fButton.selected = NO;
    }else{
        self.mButton.selected = NO;
    }
    
    sender.selected = YES;
    sexIndex = sender.tag;
}
- (IBAction)submitAction:(id)sender {
    [[ActivityModel sharedModel] userApplyWithActID:_actId voteName:_nameField.text sex:[NSString stringWithFormat:@"%d",sexIndex] tel:_phoneField.text result:^(BOOL success, NSString *msg) {
        if (success) {
            [SVProgressHUD showSuccessWithStatus:msg];
            [self.navigationController popViewControllerAnimated:YES];
        }else{
            [SVProgressHUD showErrorWithStatus:msg];
        }
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source



@end
